{% extends 'generic/object_retrieve.html' %}
{% load helpers %}

{% block content_left_page %}
    <div class="card">
        <div class="card-header">
            <strong>Cluster</strong>
        </div>
        <table class="table table-hover card-body attr-table">
            <tr>
                <td>Name</td>
                <td>{{ object.name }}</td>
            </tr>
            <tr>
                <td>Type</td>
                <td>{{ object.cluster_type|hyperlinked_object }}</td>
            </tr>
            <tr>
                <td>Group</td>
                <td>{{ object.cluster_group|hyperlinked_object }}</td>
            </tr>
            <tr>
                <td>Tenant</td>
                <td>{{ object.tenant|hyperlinked_object }}</td>
            </tr>
            <tr>
                <td>Location</td>
                <td>{% include 'dcim/inc/location_hierarchy.html' with location=object.location %}</td>
            </tr>
            <tr>
                <td>Virtual Machines</td>
                <td><a href="{% url 'virtualization:virtualmachine_list' %}?cluster_id={{ object.pk }}">{{ object.virtual_machines.count }}</a></td>
            </tr>
        </table>
    </div>
    <div class="card">
        <div class="card-header">
            <strong>Comments</strong>
        </div>
        <div class="card-body nb-rendered-markdown">
            {% if object.comments %}
                {{ object.comments|render_markdown }}
            {% else %}
                <span class="text-secondary">None</span>
            {% endif %}
        </div>
    </div>
{% endblock content_left_page %}

{% block content_right_page %}
    <div class="card">
        <div class="card-header">
            <strong>Host Devices</strong>
        </div>
        {% if perms.virtualization.change_cluster %}
            <form action="{% url 'virtualization:cluster_remove_devices' pk=object.pk %}" method="post">
                {% csrf_token %}
        {% endif %}
        {% include 'responsive_table.html' with table=device_table %}
        {% if perms.virtualization.change_cluster %}
            <div class="card-footer d-print-none">
                <div class="float-end">
                    <a href="{% url 'virtualization:cluster_add_devices' pk=object.pk %}?location={{ object.location.pk }}" class="btn btn-primary btn-sm">
                        <span class="mdi mdi-plus-thick" aria-hidden="true"></span>
                        Add devices
                    </a>
                </div>
                <button type="submit" name="_remove" class="btn btn-danger primary btn-sm">
                    <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span>
                    Remove devices
                </button>
            </div>
            </form>
        {% endif %}
    </div>
{% endblock content_right_page %}
